package com.j.lemon.learn.bookkeeper;

import org.apache.bookkeeper.client.BKException;
import org.apache.bookkeeper.client.BookKeeper;
import org.apache.bookkeeper.client.BookieInfoReader;
import org.apache.bookkeeper.client.LedgerHandle;
import org.apache.bookkeeper.meta.LedgerManager;
import org.apache.bookkeeper.net.BookieSocketAddress;

import java.io.IOException;
import java.util.Map;
import java.util.Set;

/**
 * @Author lijunjun
 * @Date 2020/9/25 17:01
 * @Description
 */
public class BookkeeperTest {
    public static void main(String[] args) throws InterruptedException, IOException, BKException {
        BookKeeper client = BookkeeperClient.getClient();

        Map<BookieSocketAddress, BookieInfoReader.BookieInfo> bookieInfo = client.getBookieInfo();
        bookieInfo.forEach((k,v)->{
        });
        LedgerManager ledgerManager = client.getLedgerManager();
        LedgerManager.LedgerRangeIterator ledgerRanges = ledgerManager.getLedgerRanges();
        while(ledgerRanges.hasNext()){
            LedgerManager.LedgerRange next = ledgerRanges.next();
            Set<Long> ledgers = next.getLedgers();
            System.out.println(ledgers);
        }
        System.out.println("aaa");

    }
}
